#include "InetAddr.hpp"
#include "Log.hpp"
#include <memory>
#include <string>
#include "UdpServer.hpp"
#include "Dict.hpp"
using namespace LogModule;
std::string handler(const std::string& s) {
    std::string hand = "hello# ";
    hand += s;
    return hand;
}
int main(int argc, char* argv[]) {
    if(argc != 2) {
        cout << "The usage is " << argv[0] << "+port" << endl;
        return 1;
    }
    uint16_t port = std::stoi(argv[1]);
    EnableConsoleLogStrategy();
    Dict dict;
    dict.LoadDict();
    std::unique_ptr<UdpServer> udp = std::make_unique<UdpServer>(port, [&dict](const string& word, InetAddr& ia)->std::string{
        return dict.Translate(word, ia);
    });
    udp->Init();
    udp->Start();
    return 0;
}